<?php
/**
 * Created by PhpStorm.
 * User: zhangrxiang
 * Date: 2017/1/3
 * Time: 13:18
 */
//parse_url — 解析 URL，返回其组成部分
//mixed parse_url ( string $url [, int $component = -1 ] )
//scheme - 如 http
//host
//port
//user
//pass
//path
//query - 在问号 ? 之后
//fragment - 在散列符号 # 之后

$url = 'http://username:password@hostname/path?arg=value#anchor';
//[scheme] => http  协议
//[host] => hostname 主机
//[user] => username 用户
//[pass] => password 密码
//[path] => /path 路径
//[query] => arg=value 参数
//[fragment] => anchor
print_r(parse_url($url));
echo parse_url($url, PHP_URL_PATH).PHP_EOL;
echo parse_url($url, PHP_URL_FRAGMENT).PHP_EOL;

$url = "http://php.net/manual/zh/function.parse-url.php";
$parse_url = parse_url( $url );
//'scheme' =>
//  string(4) "http"
//  'host' =>
//  string(7) "php.net"
//  'path' =>
//  string(33) "/manual/zh/function.parse-url.php"
var_dump($parse_url);